package day_2022_4_to_7.day48;

import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/07/06 10:33
 **/
public class Day44_2_InversionString {

    public static void main1(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] sp = sc.nextLine().split("[^a-zA-Z]+");
        StringBuilder sb = new StringBuilder();
        for (int i = sp.length - 1; i >= 0; i--)
            sb.append(sp[i] + " ");
        System.out.println(sb.toString().trim());
        sc.close();
    }

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String result = "";

        // 将输入的字符串，多个连续符号空格改为一个空格
        for(int i = 0;i < str.length();){
            char a = str.charAt(i);
            if(!Character.isLetter(a)){
                result += " ";
                i++;
                while(i < str.length() && !Character.isLetter(str.charAt(i))){
                    i++;
                }
            }else{
                result += a;
                i++;
            }
        }
        result = result.trim();
        String[] data = result.split(" ");
        String ret = "";

        // 倒置接收
        for(int i = data.length - 1;i >= 0;i--){
            ret +=  (data[i] + " ");
        }
        System.out.println(ret);
    }
}